1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
pub use super::*;
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum Command {
Expr(Expr),
Stmt(Stmt),
Code(Expr),
Id(Expr),
Addr(Expr),
Flags(Expr),
Tyck(Expr),
}
pub fn command(input: &str) -> IResult<&str, Command> {
alt((
map(expr, Command::Expr),
map(stmt, Command::Stmt),
map(preceded(preceded(tag("#code"), ws), expr), Command::Code),
map(preceded(preceded(tag("#id"), ws), expr), Command::Id),
map(preceded(preceded(tag("#addr"), ws), expr), Command::Addr),
map(preceded(preceded(tag("#flags"), ws), expr), Command::Flags),
map(preceded(preceded(tag("#tyck"), ws), expr), Command::Tyck),
))(input)
}